/***************************************************************************
 * Open Object Oriented ANSI C                                             *
 ***************************************************************************
 * Code given under the terms of GNU General Public Licence (GPLv3)        *
 * and without any waranties of any kind including but not limitative to   *
 * waranties on merchandability or any particular applications fitness.    *
 * For more information on GNU/GPL go on :                                 *
 * "http://www.gnu.org/copyleft/gpl.html"                                  *
 *                                                                         *
 * You are allowed to use it for any purposes in the terms of GNU/GPLv3    *
 * (or more).                                                              *
 * This text MUST stay in state on copyed sources (or sources using it)    *
 * and must not be altered.                                                *
 * You are allowed to add your name at the end of the Copylefs list.       *
 ***************************************************************************
 * Copylefts List :                                                        *
 ***************************************************************************
 * 2010-03-20 Patrick PIGNOL <pignol_patrick@hotmail.com> (Original)       *
 * (Type your name here if needed)                                         *
 ***************************************************************************/
#ifndef PIPE_H_INCLUDED
#define PIPE_H_INCLUDED

#define PIPE_TYPEID 2

typedef struct Pipe Pipe;
typedef struct PipeVirtualTable PipeVirtualTable;

#include "Class.h"

struct PipeVirtualTable
{
    unsigned long int TypeID;
    ClassInterface* Interface;
    ClassVirtualTable* AncestorTable;
    unsigned long int ReferenceCount;
    Pipe* (*new)(unsigned long int pArgsCount, va_list* pParameters);
    PipeVirtualTable* (*Initialize)(Pipe* this, unsigned long int pArgsCount, va_list* pParameters);
    void (*Garbage)(Pipe* this);
    unsigned long int (*TypeOf)(Pipe* this);
    bool (*IsSameTypeThanTypeID)(Pipe* this, unsigned long int pTypeID);
    bool (*IsKindOfTypeID)(Pipe* this, unsigned long int pTypeID);
    bool (*IsSameTypeThan)(Pipe* this, Class* pSource);
    bool (*IsKindOf)(Pipe* this, Class* pSource);
};

/*FIFO Agregator Class*/

struct Pipe
{
    PipeVirtualTable* VirtualTable;
    void (*Constructor)(Pipe* this, unsigned long int pArgsCount, va_list* pParameters);
    void (*Destructor)(Pipe* this);
    Pipe* (*Clone)(Pipe* this);
    Class** aPipe;
    unsigned long int aCount;
    void (*Push)(Pipe* this, Class* pObject);
    Class* (*Pop)(Pipe* this);
    unsigned long int (*Count)(Pipe* this);
};

Pipe* PipeNew(unsigned long int pArgsCount, va_list* pParameters);
PipeVirtualTable* PipeInitialize(Pipe* this, unsigned long int pArgsCount, va_list* pParameters);
void PipeConstructor(Pipe* this, unsigned long int pArgsCount, va_list* pParameters);
void PipeDestructor(Pipe* this);
Pipe* PipeClone(Pipe* this);
void PipePush(Pipe* this, Class* pObject);
Class* PipePop(Pipe* this);
unsigned long int PipeCount(Pipe* this);

#endif /* PIPE_H_INCLUDED*/
